﻿/**************************************************************
 * Description:
 * AITBarCodeBListUIModelAction.cs
 * Product: U9
 * Co.    : UFSoft Group
 * Author : Auto Generated 
 * version: 1.0
 **************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFIDA.UBF.Query.CommonService;
using UFSoft.UBF.UI.FormProcess;
using UFSoft.UBF.UI.ControlModel;
using UFIDA.UBF.Query.CommonService.QueryStrategy;
using UFIDA.UBF.Query.CaseModel;
using UFIDA.U9.UI.PDHelper;
using UFSoft.UBF.ExportService;
using System.Data;
using UFSoft.UBF.Util.DataAccess;
using UFIDA.U9.CUST.AITBarCodeBP;
using UFIDA.U9.CUST.AITBarCodeBP.Proxy;




namespace UFIDA.U9.CUST.AITBarCodeBListUIModel
{
	public partial class AITBarCodeBListUIModelAction 
	{
        public override void OnInitAction()
		{
			base.OnInitAction();
			//提示:可注册你自己的方法到相应的事件中,如下.
			//this.CommonAction.BeforeLoad += new ActionLoadDelegate(CommonAction_BeforeLoad);
		}
        private void OnLookCase_Extend(object sender, UIActionEventArgs e)
        {
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.OnLookCase_DefaultImpl(sender, e);
        }
        private void OnCaseChanged_Extend(object sender, UIActionEventArgs e)
        {
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.OnCaseChanged_DefaultImpl(sender, e);
        }
        private void OnOutPut_Extend(object sender, UIActionEventArgs e)
        {
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.OnOutPut_DefaultImpl(sender, e);
        }
        private void OnEdit_Extend(object sender, UIActionEventArgs e)
        {
            IList<IUIRecord> recs = this.CurrentModel.AITBarCode.Cache.GetSelectRecord();
            if (recs == null || recs.Count == 0)
                throw new Exception("请选择记录");
            List<long> ids = new List<long>();
            foreach(var rec in recs)
            {
                ids.Add((long)rec["ID"]);
            }
            this.CurrentPart.CurrentSessionState["BarIDS"] = ids;
            //单据页面装配的URI
            string CardPageID = "UFIDA.U9.CUST.AITBarCodeForm";
            this.CommonAction.CurrentPart.NavigatePage(CardPageID, null);

            this.OnEdit_DefaultImpl(sender, e);
        }

        private void OnGridRowDbClick_Extend(object sender, UIActionEventArgs e)
		{
            //通过this.CurrentModel.ViewName访问到记录的MainID字段，一定是MainIDstring 
            string DataID = this.CurrentModel.AITBarCode.FocusedRecord["ID"].ToString();
            //单据页面装配的URI    
            string CardPageID = "UFIDA.U9.CUST.AITBarCodeForm";
            this.OnNavigatCard("Browse",DataID,CardPageID);
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.OnGridRowDbClick_DefaultImpl(sender, e);
		}

        private void OnNavigatCard(string type, string dataID, string formID)
        {
            string FormID = formID;//AddFormID    
            string DataID = dataID;
            if (DataID == String.Empty && type == "Browse")
            {
                return;
            }
            else
            {
                System.Collections.Specialized.NameValueCollection nameValCol = new System.Collections.Specialized.NameValueCollection();
                nameValCol.Add("PDPageStatus", type);
                nameValCol.Add("ID", DataID);
                this.CommonAction.CurrentPart.NavigatePage(FormID, nameValCol);
            }
        }

        private void OnNew_Extend(object sender, UIActionEventArgs e)
		{
			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.OnNew_DefaultImpl(sender, e);
			//单据页面装配的URI    
			string CardPageID = "UFIDA.U9.CUST.AITBarCodeForm";
			this.CommonAction.CurrentPart.NavigatePage(CardPageID, null);
		}
		private void OnPrint_Extend(object sender, UIActionEventArgs e)
		{
            //打印设置
            IExportSettings settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();
            settings.PrintTemplateCatalogType = "UFIDA.U9.CUST.AITCode";
            settings.UserDataCallBack = new DataCallBackHandle(this.GetPrintData);
            e.Tag = settings;
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.OnPrint_DefaultImpl(sender,e);								
        }

        private void GetPrintData(object sender, DataCallBackEventArgs args)
        {
            //DataSet returnDataSet = null;
            //switch (args.PrintTemplateID)
            //{
            //    //条码打印
            //    case "d92bb02a-372b-4739-8542-f0492e87d245":
            //        returnDataSet = this.GetBarCodeData(args.PrintTemplateID);
            //        break;
            //    default:
            //        break;
            //}
            args.ReturnData = this.GetBarCodeData(args.PrintTemplateID);
            this.NavigateAction.Refresh(null);
        }

        private DataSet GetBarCodeData(string PrintTemplateID)
        {
            DataSet ds=new DataSet();
            IList<IUIRecord> recs = this.CurrentModel.AITBarCode.Cache.GetSelectRecord();
            List<long> ids = new List<long>();
            foreach (IUIRecord record in recs)
            {
                ids.Add((long)record["ID"]);
            }

            PrintBarCodeProxy proxy = new PrintBarCodeProxy();
            proxy.IDS = ids;
            proxy.PrintTemplateID = PrintTemplateID;
            PrintAITBarCodeDTOData retdto = proxy.Do();
            ds = (DataSet)retdto.Data;
            return ds;
        }

        private void OnDelete_Extend(object sender, UIActionEventArgs e)
		{
	
			

			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
this.OnDelete_DefaultImpl(sender,e);								
        } 
		
		#region UBF 内置两数据处理Action
		//数据加载的扩展
		private void OnLoadData_Extend(object sender, UIActionEventArgs e)
		{
this.OnLoadData_DefaultImpl(sender,e);			
		}

		//数据收集的扩展
		private void OnDataCollect_Extend(object sender, UIActionEventArgs e)
		{
			this.OnDataCollect_DefaultImpl(sender,e);
		}
		#endregion 
		
		  

		    
        #region 列表应用开发人员扩展代码段
        
        private string CustomFilterOpath_Extend(string filterOpath)
        {
            return filterOpath;
        }
        
	private void AfterQryAdjust_Extend(IUFDataGrid UIGrid)
        {

        }

	
        private void BeforeGetQryModel_Extend(BEQueryStrategyImpl beQryStrategyImpl)
        {
        }

        private void AfterGetQueryModel_Extend(CaseModel caseModel)
        {
        }
        
        #endregion
		  

	}
}
